/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package polandballgame;
import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author POed
 */
public class SwampObject extends GameObject {
    
    private int movesToLeave;
	
    // Constructor
    public SwampObject(int xPos, int yPos) {
        
        super(xPos, yPos);
        type = 4;
        passable = true;
        
        resetSwamp();
    }

    // resets movesToLeave;
    public void resetSwamp() {
        movesToLeave = 4;
    }

    // returns true when movesToLeave is equal to 0 else returns false, also decreases movesToLeave
    public boolean tryToLeave() {
        
        if (--movesToLeave < 0) {
            this.resetSwamp();
            return true;
        }
        else {
            return false;
        }
    }

    // Drawing
    @Override public void draw(Graphics context) {
    
        context.setColor(Color.green);
        context.fillRect(x * Engine.cellSize, y * Engine.cellSize, Engine.cellSize, Engine.cellSize);
    }
    
}
